<template>
	<view class="content">
        <!-- navbar -->
        <u-navbar :fixed="true" :shadow="true" :safeAreaInsetTop="true" :placeholder="true"
            leftIconColor="#151C24" @leftClick="back"
            title="专户管理" titleColor="#151C24">
        </u-navbar>

        <!-- content -->
        <view class="uni-area">
            <!-- 专户统计 -->
            <view class="u-m-t-50 u-font-32 font-bold">专户统计</view>
            <uni-item-base class="u-m-t-20 u-p-t-0" :baseData="total" />
            <!-- 工资专户 -->
            <u-button class="u-m-t-50 wage" type="primary" text="专户详情" @tap="skip"></u-button>
        </view>

        <!-- 提示组件 -->
        <u-toast ref="uToast"></u-toast>
	</view>
</template>

<script>
	export default {
		data() {
			return {
                // 用户信息
                userInfo: uni.getStorageSync("userInfo"),
                parameter:{
                    deptId: null, // 所属部门编号
                    gcbh: null // 所属项目(工程)编号
                },
                // 专户统计
                total:{
                    line: false,
                    title: '',
                    rightText: '',
                    list:[
                        { filed:'account', title:'专户数', value:'', unit:'个' },
                        { filed:'balance', title:'拨付金额', value:'', unit:'万元' },
                        { filed:'disburse', title:'发放金额', value:'', unit:'万元' },
                        { filed:'salary', title:'专户余额', value:'', unit:'万元' },
                    ]
                },
			}
		},

		onLoad() {
            // // console.log('用户信息',this.userInfo)
            this.parameter.deptId = this.userInfo.deptId,
            this.parameter.gcbh = this.userInfo.ssgcbh,
            // 专户统计
            this.getAccAccStatistics()
		},
    
		methods: {
            // 返回
            back(){
                uni.navigateBack()
            },

            // 专户统计
            getAccAccStatistics(){
                this.$request(this,this.$apis.fohfAccStatistics,{}).then(res=>{
                    // console.log('专户统计',res)
                    this.total.list.map((v,i)=>{
                        v.value = res[v.filed]
                    })
                }).then()
            },

            // 专户详情
            skip(){
                // 先调用工资专户信息拿到业务编号(人设端文档)
                uni.showLoading({ title:'专户详情加载中' })
                this.$request(this,this.$apis.AccAccsSalary, {gcbh:this.parameter.gcbh}).then(res=>{
                    // console.log('工资专户信息',res)
                    uni.navigateTo({ url: '/pages/fohf-bag/detail?id='+res.id })
                }).then()
            },
		}
	}
</script>

<style scoped lang="scss">
    .content{
        .wage{
            border-radius: 20rpx;
        }
    }
</style>
